package ee.videorentalstore.users;

public abstract class User 
{
	private static int nextUserUID = 1;
	private int userID = 0;
	protected String name = "no name entered";
	
	
	public User()
	{
		setUserUID();
		UsersDatabase.getInstance().registerANewUser(this);
	}

	
	public abstract String getUserTypeName();
	public abstract void setUserName(String name);
	public abstract String getUserName();
	
	
	@Override
	public int hashCode() 
	{
		final int prime = 31;
		int result = 1;
		result = prime * result + userID;
		return result;
	}

	@Override
	public boolean equals(Object obj)
	{
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		User other = (User) obj;
		if (userID != other.userID)
			return false;
		return true;
	}

	private void setUserUID()
	{
		userID = nextUserUID; // set id to next available id
		nextUserUID++;
	}
	public int getUserID()
	{
		return userID;
	}
}
